package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.autoFill.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {


    @Select("select count(*) from dish where id=#{id}")
    Integer countByCategoryId(Integer id);

    /**
     * 分页查询
     * @return
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 添加菜品
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);

    /**
     * 根据id查询菜品
     * @param id
     * @return
     */
    @Select("select id,name,category_id,image,description,status,update_time,price from dish where id=#{id}")
    Dish getById(Long id);

    /**
     * 根据分类id查询菜品
     */
    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> getByCategoryId(Long categoryId);

    /**
     * 更改菜品信息
     * @param dish
     */
    @AutoFill(OperationType.UPDATE)
    void changeDish(Dish dish);

    /**
     * 根据id删除菜品
     * @param ids
     */
    void deleteDishs(List<Long> ids);

}
